/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mundo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author USUARIO WINDOWS
 */
@Entity
@Table(name = "cliente")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cliente.findAll", query = "SELECT c FROM Cliente c"),
    @NamedQuery(name = "Cliente.findByTipoCliente", query = "SELECT c FROM Cliente c WHERE c.tipoCliente = :tipoCliente"),
    @NamedQuery(name = "Cliente.findByPersonaidPersona", query = "SELECT c FROM Cliente c WHERE c.personaidPersona = :personaidPersona")})
public class Cliente implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "tipo_cliente")
    private String tipoCliente;
    @Id
    @Basic(optional = false)
    @Column(name = "Persona_idPersona")
    private Integer personaidPersona;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idCliente")
    private Collection<Venta> ventaCollection;
    @JoinColumn(name = "Persona_idPersona", referencedColumnName = "idPersona", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Persona persona;

    public Cliente() {
    }

    public Cliente(Integer personaidPersona) {
        this.personaidPersona = personaidPersona;
    }

    public String getTipoCliente() {
        return tipoCliente;
    }

    public void setTipoCliente(String tipoCliente) {
        this.tipoCliente = tipoCliente;
    }

    public Integer getPersonaidPersona() {
        return personaidPersona;
    }

    public void setPersonaidPersona(Integer personaidPersona) {
        this.personaidPersona = personaidPersona;
    }

    @XmlTransient
    public Collection<Venta> getVentaCollection() {
        return ventaCollection;
    }

    public void setVentaCollection(Collection<Venta> ventaCollection) {
        this.ventaCollection = ventaCollection;
    }

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (personaidPersona != null ? personaidPersona.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cliente)) {
            return false;
        }
        Cliente other = (Cliente) object;
        if ((this.personaidPersona == null && other.personaidPersona != null) || (this.personaidPersona != null && !this.personaidPersona.equals(other.personaidPersona))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mundo.Cliente[ personaidPersona=" + personaidPersona + " ]";
    }
    
}
